module.exports = (mod)->
    beforeRouteEnter = mod.beforeRouteEnter

    mod.beforeRouteEnter = (to, from,  next)->
        if await $.getJSON("*auth/user/id")
            next(false)
            GO.push "/"
            return
        if beforeRouteEnter
            beforeRouteEnter.apply @,arguments
        else
            next()
    return mod
